//
//  GroupNoticeViewController.m
//  PigMarket
//
//  Created by mac on 2019/6/20.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "GroupNoticeViewController.h"

@interface GroupNoticeViewController ()
/**
 bgview
 */
@property (nonatomic , strong) UIView *bgView;
/**
 头像
 */
@property (nonatomic , strong)  UIImageView *headImg;
/**
 name
 */
@property (nonatomic , strong) UILabel *nameLab;
/**
 time
 */
@property (nonatomic , strong) UILabel *timeLab;
/**
 line
 */
@property (nonatomic , strong) UIView *line;
/**
 群主可编辑
 */
@property (nonatomic , strong) UILabel *limitLab;
/**
 公告内容
 */
@property (nonatomic , strong) UILabel *detailLab;
@end

@implementation GroupNoticeViewController


#pragma mark - view life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"群公告";
    [self setUpView];
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

-(void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

#pragma mark - init method
- (void)setUpView {
    [self initView];
    [self initLayout];
    [self initAction];
    [self initData];
}
- (void)initView {
    [self.view addSubview:self.bgView];
    [self.bgView addSubview:self.headImg];
    [self.bgView addSubview:self.nameLab];
    [self.bgView addSubview:self.timeLab];
    [self.bgView addSubview:self.line];
    [self.bgView addSubview:self.limitLab];
    [self.bgView addSubview:self.detailLab];
}

- (void) initLayout {
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(10);
    }];
    [self.headImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(15);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImg.mas_right).offset(10);
        make.top.mas_equalTo(15);
        make.height.mas_equalTo(18);
        make.right.mas_equalTo(-15);
    }];
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImg.mas_right).offset(10);
        make.top.mas_equalTo(self.nameLab.mas_bottom).offset(7);
        make.height.mas_equalTo(18);
        make.right.mas_equalTo(-15);
    }];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.headImg.mas_bottom).offset(15);
        make.height.mas_equalTo(1);
    }];
    [self.limitLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-80);
        make.centerX.mas_equalTo(self.bgView.mas_centerX);
        make.height.mas_equalTo(18);
    }];
    [self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(self.line.mas_bottom).offset(6);
        make.right.mas_equalTo(-15);
        make.bottom.mas_equalTo(self.limitLab.mas_top).offset(-100);
    }];

}

- (void) initAction {
    
}

- (void)initData {
    self.headImg.backgroundColor = [UIColor redColor];
    self.nameLab.text = self.groupInfo.owner;
    self.timeLab.text = [NSString transferTimeStamp:[self.groupInfo.owner doubleValue]];
    self.detailLab.text = self.groupInfo.notification;

}

#pragma mark - delegate

#pragma mark - target action

#pragma mark - private method

#pragma mark - getter and setter
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}
- (UIImageView *)headImg {
    if (!_headImg) {
        _headImg = [[UIImageView alloc] init];
        _headImg.layer.cornerRadius = 20;
        _headImg.layer.masksToBounds = YES;
    }
    return _headImg;
}
- (UILabel *)nameLab {
    if (!_nameLab) {
        _nameLab = [[UILabel alloc] init];
        _nameLab.textColor = [UIColor colorWithHexString:@"#333333"];
        _nameLab.font = [UIFont systemFontOfSize:13];
    }
    return _nameLab;
}
- (UILabel *)detailLab {
    if (!_detailLab) {
        _detailLab = [[UILabel alloc] init];
        _detailLab.textColor = [UIColor colorWithHexString:@"#414141"];
        _detailLab.font = [UIFont systemFontOfSize:16];
    }
    return _detailLab;
}
- (UILabel *)timeLab {
    if (!_timeLab) {
        _timeLab = [[UILabel alloc] init];
        _timeLab.textColor = [UIColor colorWithHexString:@"#B0B0B0"];
        _timeLab.font = [UIFont systemFontOfSize:13];
    }
    return _timeLab;
}
- (UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = [UIColor colorWithHexString:@"#F7F7F7"];
    }
    return _line;
}
- (UILabel *)limitLab {
    if (!_limitLab) {
        _limitLab = [[UILabel alloc] init];
        _limitLab.textColor = [UIColor colorWithHexString:@"#B0B0B0"];
        _limitLab.font = [UIFont systemFontOfSize:13];
        _limitLab.text = @"——————  仅群主可编辑  ——————";
    }
    return _limitLab;
}
@end
